package com.example.spring.jdbc.service.impl;

import com.example.spring.jdbc.dao.RougeDao;
import com.example.spring.jdbc.service.RougeService;
import com.example.spring.jdbc.service.dto.BrandInfo;
import com.example.spring.jdbc.service.dto.RougeInfo;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author : zhayh
 * @date : 2021-3-31 20:13
 * @description :
 */

@Service
public class RougeServiceImpl implements RougeService {
    @Resource
    private RougeDao rougeDao;

    @Override
    public List<BrandInfo> getAllBrandInfo() {
        return rougeDao.getAllBrandInfo();
    }

    @Override
    public RougeInfo getRougeById(Long id) {
        return rougeDao.selectById(id);
    }

    @Override
    public RougeInfo addRouge(RougeInfo rougeInfo) {
        return rougeDao.insert(rougeInfo);
    }

    @Override
    public RougeInfo updateRougePrice(Long id, Float price) {
        return rougeDao.updatePrice(id, price);
    }

    @Override
    public Boolean deleteRouge(Long id) {
        return rougeDao.delete(id) > 0;
    }

    @Override
    public Page<RougeInfo> getRougesByPage(Integer pageIndex, Integer pageSize) {
        return rougeDao.selectByPage(pageIndex, pageSize);
    }
}
